<template>
  <span @click="submitForm">
    <slot></slot>
    <form method="post" ref="form" style="visibility: hidden" :action="this.download" target="_blank">
      <input type="hidden" :name="key" :value="value" :key="key" v-for="(value, key) in this.query">
    </form>
  </span>
</template>

<script>
  export default {
    name: 'download-btn',
    props: [
      'query',
      'download'
    ],
    data () {
      return {
        value: ''
      }
    },
    methods: {
      submitForm () {
        this.$refs.form.submit()
      }
    }
  }
</script>

<style lang="less"></style>

